<template>
	<view class="userinfo">
		<!-- 头像和名字 -->
		<view class="top-box">
			<view class="avater">
				<image :src="userinfo.avatarUrl||'/static/moren.png'" mode=""></image>
			</view>
			<view class="nickname">
				{{userinfo.nickName||'默认昵称'}}
			</view>
			<view @click="updateTopbox" class="button">
				<uni-icons type="settings-filled" size="30" color="#fff"></uni-icons>
			</view>
		</view>
		<view class="panel-list">
			<!-- 收藏的店铺、商品、足迹 -->
			<view class="first">
				<view class="scdp">
					<text>8</text>
					<text>收藏的店铺</text>
				</view>
				<view class="scdp">
					<text>14</text>
					<text>收藏的商品</text>
				</view>
				<view class="scdp">
					<text>8</text>
					<text>关注的商品</text>
				</view>
				<view class="scdp">
					<text>8</text>
					<text>足迹</text>
				</view>
			</view>
			<!-- 我的订单 -->
			<view class="order">
				<view class="order-title">
					我的订单
				</view>
				<view class="order-items">
					<view class="order-item">
						<image src="../../../../static/my-icons/icon1.png" mode=""></image>
						<text>待收款</text>
					</view>
					<view class="order-item">
						<image src="../../../../static/my-icons/icon2.png" mode=""></image>
						<text>待收货</text>
					</view>
					<view class="order-item">
						<image src="../../../../static/my-icons/icon3.png" mode=""></image>
						<text>退款/退货</text>
					</view>
					<view class="order-item">
						<image src="../../../../static/my-icons/icon4.png" mode=""></image>
						<text>全部订单</text>
					</view>
				</view>

			</view>
			<!-- 收货地址、联系客服、退出登录 -->
			<view class="last">
				<view class="last-item">
					<text>收货地址</text>
					<uni-icons type="forward" size="15"></uni-icons>
				</view>
				<view class="last-item">
					<text>联系客服</text>
					<uni-icons type="forward" size="15"></uni-icons>
				</view>
				<view class="last-item" @click="logout">
					<text>退出登录</text>
					<uni-icons type="forward" size="15"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {

			}
		},
		computed: {
			...mapState('m_user', ['userinfo'])
		},
		methods: {
			...mapMutations('m_user', ['saveToaddress', 'saveUserInfo', 'updateToken']),
			updateTopbox() {
				uni.navigateTo({
					url: '/subpkg/ava_change/ava_change'
				})
			},
			logout() {
				let _this = this
				uni.showModal({
					title: '提示',
					content: '确认退出登录吗？',
					success(res) {
						if (res.confirm) {
							_this.updateToken('')
							_this.saveUserInfo({})
							_this.saveToaddress({})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.userinfo {
		background-color: #f4f4f4;
		height: 100vh;
		position: relative;

		.top-box {
			height: 400rpx;
			background-color: #c00000;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			position: relative;

			.avater {
				width: 100px;
				height: 100px;
				border-radius: 50%;
				border: 2px #fff solid;
				box-shadow: 0 1px 5px black;

				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}

			.nickname {
				margin-top: 10px;
				color: #f4f4f4;
				font-size: 16px;
				font-weight: bold;
			}

			.button {
				height: 30px;
				width: 30px;
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: #c00000;
				position: absolute;
				top: 28px;
				left: 240px;
			}
		}

		.panel-list {
			position: absolute;
			top: 370rpx;
			left: 20rpx;
			width: 710rpx;

			.first {
				border-radius: 5px;
				width: 100%;
				height: 50px;
				background-color: #fff;
				display: flex;
				justify-content: space-around;

				.scdp {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					font-size: 12px;
				}
			}

			.order {
				border-radius: 5px;
				width: 100%;
				height: 120px;
				background-color: #fff;
				margin-top: 10px;

				.order-title {
					height: 50px;
					font-size: 15px;
					margin-left: 10px;
					line-height: 50px;
					border-bottom: 1px #f4f4f4 solid;
				}

				.order-items {
					height: 70px;
					display: flex;
					justify-content: space-around;
					align-items: center;


					.order-item {
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;

						image {
							width: 30px;
							height: 30px;
						}

						text {
							font-size: 12px;
							margin-top: 5px;
						}
					}

				}
			}

			.last {
				margin-top: 10px;
				background-color: #fff;
				padding: 0 10px;
				border-radius: 5px;

				.last-item {
					height: 50px;
					font-size: 14px;
					display: flex;
					justify-content: space-between;
					align-items: center;
				}
			}
		}
	}
</style>
